﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AppLimit.CloudComputing.SharpBox.StorageProvider.DropBox;
using AppLimit.CloudComputing.SharpBox;
using AppLimit.CloudComputing.SharpBox.Exceptions;

namespace CipherBoxAuthValidation
{
    public partial class CipherBoxAuthValidationDialog : Form
    {
        public CipherBoxAuthValidationDialog()
        {
            InitializeComponent();
        }

        private void buttoncheck_Click(object sender, EventArgs e)
        {
            try
            {

                CloudStorage m_Storage = new CloudStorage();
                ICloudStorageConfiguration m_Config = DropBoxConfiguration.GetStandardConfiguration();
                m_Config = new DropBoxConfiguration();
                DropBoxCredentials m_Credentials = new DropBoxCredentials();
                m_Credentials.ConsumerKey = textBoxkey.Text;
                m_Credentials.ConsumerSecret = textBoxsecret.Text;
                m_Credentials.UserName = textBoxuser.Text;
                m_Credentials.Password = textBoxpass.Text;
                ICloudStorageAccessToken m_Token = m_Storage.Open(m_Config, m_Credentials);
                MessageBox.Show("everything is ok!");
                m_Storage.Close();
            }
            catch (SharpBoxException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show("login wrong!");
            }
        }
    }
}
